<?//=debug($user_types);?>
<div class="events form">
<?php echo $form->create('Event');?>
	<fieldset>
 		<legend><?php __('Add Event');?></legend>
	<?php
		echo $form->input('title');
	?>
<script type="text/javascript">
function find(id) { return document.getElementById(id); }
$(function() {
	$("#start_date").datepicker({onClose: function(dateText, inst) {
		var arr = dateText.split("-");
		find('start_day').value = arr[0];
		find('start_month').value = arr[1];
		find('start_year').value = arr[2];
	}});
	$('#start_date').datepicker('option', {dateFormat: 'dd-mm-yy'});
	$("#end_date").datepicker({onClose: function(dateText, inst) {
		var arr = dateText.split("-");
		find('end_day').value = arr[0];
		find('end_month').value = arr[1];
		find('end_year').value = arr[2];
	}});
	$('#end_date').datepicker('option', {dateFormat: 'dd-mm-yy'});
});
</script>
<p>Start date: <input type="text" id="start_date" /></p>
<input type="hidden" name="data[Event][start_date][day]" id="start_day" value="" />
<input type="hidden" name="data[Event][start_date][month]" id="start_month" value="" />
<input type="hidden" name="data[Event][start_date][year]" id="start_year" value="" />
<p>End date: <input type="text" id="end_date" /></p>
<input type="hidden" name="data[Event][end_date][day]" id="end_day" value="" />
<input type="hidden" name="data[Event][end_date][month]" id="end_month" value="" />
<input type="hidden" name="data[Event][end_date][year]" id="end_year" value="" />
	<?php
		echo $form->input('announcement_body');
		echo $form->input('content_body');
		echo $form->input('creator_id', array('type' => 'hidden', 'value' => $creator_id));
		echo $form->select('attendance_manager_id', $organizers, NULL, array(), '-Attendance Manager-').'<br/>';
		echo $form->select('event_type_id', $selectEvents, NULL, array(), '-Event Type-');
		echo $form->input('season_id', array('type' => 'hidden', 'value' => $season_id));
		echo $form->input('member_price');
		echo $form->input('guest_price');
		echo $form->input('Instructor');		

		$i=0;
		foreach ($user_types as $user_type){		
			if ($user_type['UserType']['id'] < 4){			
                echo $form->input('EventPrivilage.'.$i.'.user_type_id',array('type'=>'hidden','value'=>$user_type['UserType']['id']));
    			echo $form->input('EventPrivilage.'.$i.'.privilage',array('type'=>'hidden','value'=>'11'));
				$i+=1;
    			continue;
			}
			echo $user_type['UserType']['title'];			
			echo $form->input('EventPrivilage.'.$i.'.user_type_id',array('type'=>'hidden','value'=>$user_type['UserType']['id']));
    		//echo the 2 check boxes
			echo $form->input('EventPrivilage.'.$i.'.privilage-view',array('type'=>'checkbox',
			                           'label'=>'view'
			                           )
			                 );
			echo $form->input('EventPrivilage.'.$i.'.privilage-edit',array('type'=>'checkbox',
			                           'label'=>' edit'
			                           )
			                 );			                 
			//echo the hidden privilege field
			//echo $form->input('EventPrivilage.'.$i.'.privilege',array('type'=>'hidden','value'=>'11','id'=>'organizerField'));
			$i+=1;
		}
	?>
	</fieldset>
<?php echo $form->end('Submit');?>
</div>
<div class="actions">
	<ul>
		<li><?php echo $html->link(__('List Events', true), array('action' => 'index'));?></li>
	</ul>
</div>
